//
//  UIButton+Extension.m
//  ITHome
//
//  Created by lanou3g on 15/7/14.
//  Copyright (c) 2015年 YAX. All rights reserved.
//

#import "UIButton+Extension.h"

@implementation UIButton (Extension)

- (void)itemWithTitle:(NSString *)title image:(NSString *)image highImage:(NSString *)highImage titleSize:(CGFloat)titleSize
{
    [self setTitle:title forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    self.titleLabel.font = [UIFont systemFontOfSize:titleSize];
}

#pragma mark - 前进图片
- (void)itemWithImage:(NSString *)image highImage:(NSString *)highImage
{
    [self setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
}

#pragma mark - 背景图片
- (void)itemWithBackgroundImage:(NSString *)image highImage:(NSString *)highImage
{
    [self setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [self setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
}

#pragma mark - 创建一个文本button
+ (UIButton *)buttonWithFrame:(CGRect)frame title:(NSString *)titile backgroundColor:(UIColor *)color
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = frame;
    [btn setTitle:titile forState:UIControlStateNormal];
    btn.layer.cornerRadius = 3;
    btn.layer.masksToBounds = YES;
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    btn.backgroundColor = color;
    return btn;
}

#pragma mark - 创建一个图片button
+ (UIButton *)buttonWithFrame:(CGRect)frame image:(NSString *)image highImage:(NSString *)highImage
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = frame;
    [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    return btn;
}

@end
